home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / libcompress-raw-zlib-perl / examples / filtdef next >
Encoding:
Text File  |  2008-02-18  |  408 b   |  28 lines

  1. #!/usr/local/bin/perl
  2.  
  3. use Compress::Raw::Zlib ;
  4.  
  5. use strict ;
  6. use warnings ;
  7.  
  8. binmode STDIN;
  9. binmode STDOUT;
  10.  
  11. my $x = new Compress::Raw::Zlib::Deflate()
  12.    or die "Cannot create a deflation stream\n" ;
  13.  
  14. my $output = '' ;
  15.  
  16. while (<>)
  17. {
  18.     $x->deflate($_, $output) == Z_OK 
  19.         or die "deflate failed\n" ;
  20.  
  21.     print $output ;
  22. }
  23.  
  24. $x->flush($output) == Z_OK
  25.     or die "flush failed\n" ;
  26.  
  27. print $output ;
  28.